package com.itheima.d10_api_object.bean;

import java.util.Arrays;
public class User implements Cloneable{
    private int id; // 编号
    private String username; // 用户名
    private String password; // 密码
    private double[] scores; // 分数

    public User() {
    }

    public User(int id, String username,
                String password, double[] scores) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.scores = scores;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        // super去调用父类Object中的clone方法。
        User cloneUser = (User) super.clone();
        cloneUser.scores = scores.clone();
        return cloneUser;
    }
    /*
   //浅克隆操作

   @Override
    public User clone() throws CloneNotSupportedException {
        return (User) super.clone();
    }*/


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public double[] getScores() {
        return scores;
    }

    public void setScores(double[] scores) {
        this.scores = scores;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", scores=" + Arrays.toString(scores) +
                ", scores=" + scores +
                '}';
    }
}
